define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'wuliu/wlche/index' + location.search,
                    add_url: 'wuliu/wlche/add',
                    edit_url: 'wuliu/wlche/edit',
                    del_url: 'wuliu/wlche/del',
                    multi_url: 'wuliu/wlche/multi',
                    import_url: 'wuliu/wlche/import',
                    table: 'wlche',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        //
                        {field: 'id', title: __('Id'),visible: true },
                        //车号
                        {field: 'chehao', title: __('Chehao'), operate:'like' ,visible: true },
                        //车属公司
                        {field: 'checom', title: __('Checom'), operate:'like' ,visible: true },
                        //车牌属地
                        {field: 'checity', title: __('Checity'), operate:'like' ,visible: true },
                        //挂车牌号
                        {field: 'guachehao', title: __('Guachehao'), operate:'like' ,visible: true },
                        //车属性质
                        {field: 'chexingzhi', title: __('Chexingzhi'), operate:'like' ,visible: true },
                        //车型
                        {field: 'chexing', title: __('Chexing'), operate:'like' ,visible: true },
                        //驾驶员
                        {field: 'driver', title: __('Driver'), operate:'like' ,visible: true },
                        //驾驶员电话
                        {field: 'driverphone', title: __('Driverphone'), operate:'like' ,visible: true },
                        //车燃料
                        {field: 'ranliao', title: __('Ranliao'), operate:'like' ,visible: true },
                        //载重
                        {field: 'zaizhong', title: __('Zaizhong'),visible: true },
                        //型号
                        {field: 'xinghao', title: __('Xinghao'), operate:'like' ,visible: true },
                        //车架号
                        {field: 'chejia', title: __('Chejia'), operate:'like' ,visible: true },
                        //
                        {field: 'hongben', title: __('Hongben'), operate:'like' ,visible: true },
                        //红本有效期
                        {field: 'hongbenyxq', title: __('Hongbenyxq'),visible: true },
                        //黄本
                        {field: 'huangben', title: __('Huangben'), operate:'like' ,visible: true },
                        //黄本有效期
                        {field: 'huangbenyxq', title: __('Huangbenyxq'),visible: true },
                        //蓝本
                        {field: 'lanben', title: __('Lanben'), operate:'like' ,visible: true },
                        //蓝本有效期
                        {field: 'lanbenyxq', title: __('Lanbenyxq'),visible: true },
                        //养路费
                        {field: 'yanglufei', title: __('Yanglufei'), operate:'BETWEEN',visible: true },
                        //养路费有效期
                        {field: 'yanglufeiyxq', title: __('Yanglufeiyxq'),visible: true },
                        //
                        {field: 'xingshizheng', title: __('Xingshizheng'), operate:'like' ,visible: true },
                        //行驶证有效期
                        {field: 'xingshizhengyxq', title: __('Xingshizhengyxq'),visible: true },
                        //保险
                        {field: 'baoxian', title: __('Baoxian'), operate:'like' ,visible: true },
                        //保险有效期
                        {field: 'baoxianyxq', title: __('Baoxianyxq'),visible: true },
                        //保险公司
                        {field: 'baoxiancom', title: __('Baoxiancom'), operate:'like' ,visible: true },
                        //保险电话
                        {field: 'baoxianphone', title: __('Baoxianphone'), operate:'like' ,visible: true },
                        //保额
                        {field: 'baomoney', title: __('Baomoney'), operate:'BETWEEN',visible: true },
                        //保养日期
                        {field: 'baoyangrq', title: __('Baoyangrq'),visible: true },
                        //保养里程
                        {field: 'baoyangmile', title: __('Baoyangmile'),visible: true },
                        //下次保养日期
                        {field: 'baoyangnextdate', title: __('Baoyangnextdate'),visible: true },
                        //下次保养里程
                        {field: 'baoyangnextmile', title: __('Baoyangnextmile'),visible: true },
                        //保养内容
                        {field: 'baoyangxiangmu', title: __('Baoyangxiangmu'), operate:'like' ,visible: true },
                        //维护日期
                        {field: 'weihudate', title: __('Weihudate'),visible: true },
                        //维护内容
                        {field: 'weihuxiangmu', title: __('Weihuxiangmu'), operate:'like' ,visible: true },
                        //下次维护日期
                        {field: 'weihunextdate', title: __('Weihunextdate'),visible: true },
                        //车辆编组
                        {field: 'bianzu', title: __('Bianzu'), operate:'like' ,visible: true },
                        //组长长车辆
                        {field: 'zuzhangche', title: __('Zuzhangche'), operate:'like' ,visible: true },
                        //组长电话
                        {field: 'zuzhangphone', title: __('Zuzhangphone'), operate:'like' ,visible: true },
                        //定位型号
                        {field: 'gpsxinghao', title: __('Gpsxinghao'), operate:'like' ,visible: true },
                        //定位厂家
                        {field: 'gpschangjia', title: __('Gpschangjia'), operate:'like' ,visible: true },
                        //车载对讲
                        {field: 'duijiang', title: __('Duijiang'), operate:'like' ,visible: true },
                        //对讲编号
                        {field: 'duijianghao', title: __('Duijianghao'), operate:'like' ,visible: true },
                        //轮胎风炮
                        {field: 'fengpao', title: __('Fengpao'),visible: true },
                        //锅灶
                        {field: 'guozao', title: __('Guozao'),visible: true },
                        //分期开始
                        {field: 'fenqistart', title: __('Fenqistart'),visible: true },
                        //期数
                        {field: 'fenqiqishu', title: __('Fenqiqishu'),visible: true },
                        //分期金额
                        {field: 'fenqimoney', title: __('Fenqimoney'), operate:'BETWEEN',visible: true },
                        //还款日期
                        {field: 'huankuandate', title: __('Huankuandate'),visible: true },
                        //剩余期数
                        {field: 'fenqileft', title: __('Fenqileft'),visible: true },
                        //照片1
                        {field: 'cheimg1', title: __('Cheimg1'), operate:'like' ,visible: true },
                        //照片2
                        {field: 'cheimg2', title: __('Cheimg2'), operate:'like' ,visible: true },
                        //铭牌
                        {field: 'mingpai', title: __('Mingpai'), operate:'like' ,visible: true },
                        //养路费照片
                        {field: 'yanglufeiimg', title: __('Yanglufeiimg'), operate:'like' ,visible: true },
                        //创建时间
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', datetimeFormat:'YYYY/MM/DD' , formatter: Table.api.formatter.datetime},
                        //更新时间
                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', datetimeFormat:'YYYY/MM/DD' , formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
